import AttributeUtil from '@/AttributeUtil';

export default class MathCommon {
    static calulateReduce(a: number, r: number = 0.02, base = 2) {
        if (a == 0) {
            return 0;
        } else if (a < 0) {
            a = -a;
            return -(a / (a + base / r));
        }
        return a / (a + base / r);
    }
    static getAbilityEffectCount(base: number, caster: unit, abilityId: string | number) {
        let attr = AttributeUtil.getUnitAttribute(caster);
        if (attr != null) {
            if (typeof abilityId == 'number') {
                abilityId = id2string(abilityId);
            }
            base += (attr?.[abilityId + '_effect_count'] as number) ?? 0;
        }
        return base;
    }
}
